--[[ 编码: WMS-01-18 名称: 批量新增料箱-初始化 作者:HAN 日期:2025-4-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: DlgInitial 功能: -- 弹出自定义表单编辑 容器类型定义 属性时,初始化自定义表单界面 更改记录: --]] wms_base = require( "wms_base" ) function DlgInitial ( strLuaDEID ) local nRet, strRetInfo, n, nCount local choice_items = {} local strCondition, ctd_code local strOrder = 'S_CTD_CODE' strCondition = "" nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Container_Type_Def", strCondition, strOrder,"S_CTD_CODE","S_NAME" ) if (nRet ~= 0) then lua.Stop( strLuaDEID, "获取【Container_Type_Def】信息失败! " .. strRetInfo ) return end ctd_code = '' if ( strRetInfo ~= '' ) then local ctd_set = {} local success local attrs success, ctd_set = pcall( json.decode, strRetInfo) if ( success == false ) then lua.Stop( strLuaDEID, "获取【Container_Type_Def】信息失败! 非法的JSON格式!"..ctd_set ) return end nCount = #ctd_set -- 组织下拉列表选项 local ctd_name for n = 1, nCount do attrs = ctd_set[n].attrs ctd_name = attrs[2].value choice_items[n] = attrs[1].value if ( ctd_name ~= '' ) then choice_items[n] = choice_items[n].."/"..ctd_name end end -- 如果只有一个仓库,那么就默认选这个仓库 if ( nCount == 1) then ctd_code = choice_items[1] end end if ( #choice_items == 0 ) then return end local action = { { action_type = "set_dlg_attr", value = { { attr = "S_CTD_CODE", value = ctd_code, choice_list = choice_items } } } } nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action ) ) if ( nRet ~= 0 ) then lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction ) return end end